import request from "@/utils/request.js";
//获取用户列表

export function getUsers(data) {
  return request({
    url: "users",
    method: "GET",
    params: data,
  });
}

//添加用户
export function addUsers(data) {
  return request({
    url: "users",
    method: "post",
    data,
  });
}

//修改用户状态
export function updateUsersState(uId, type) {
  return request({
    url: `users/${uId}/state/${type}`,
    method: "put",
  });
}

//根据id查询用户信息
export function getUsersById(id) {
  return request({
    url: `users/${id}`,
    method: "GET",
  });
}

//修改用户信息
export function updateUserInfo(data) {
  return request({
    url: `users/${data.id}`,
    method: "put",
    data: { email: data.email, mobile: data.mobile },
  });
}

//删除用户信息
export function deleteUserInfo(id) {
  return request({
    url: `users/${id}`,
    method: "delete",
  });
}

// 分配用户角色
export function updateUserRole(data) {
  return request({
    url: `users/${data.id}/role`,
    method: "put",
    data: { rid: data.rid },
  });
}
